package cn.turboinfo.dongying.api.domain.common.service.user;

import cn.turboinfo.dongying.api.entity.common.enumeration.common.EntityObjectType;
import cn.turboinfo.dongying.api.entity.common.enumeration.user.UserType;
import cn.turboinfo.dongying.api.entity.common.exception.user.UserTypeRelException;
import cn.turboinfo.dongying.api.entity.common.pojo.user.UserTypeRel;
import net.sunshow.toolkit.core.qbean.api.request.QPage;
import net.sunshow.toolkit.core.qbean.api.request.QRequest;
import net.sunshow.toolkit.core.qbean.api.response.QResponse;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

/**
 * 用户类型服务
 */
public interface UserTypeRelService {

    List<UserTypeRel> findByUserId(Long userId);

    /**
     * 创建公司和用户关联
     *
     * @param userId
     * @param shopId
     * @return
     * @throws UserTypeRelException
     */
    UserTypeRel createShopRel(Long userId, Long shopId) throws UserTypeRelException;

    /**
     * 是否有公司关联
     */
    boolean hasShopRel(Long userId, Long shopId);

    /**
     * 创建普通消费者关联
     */
    UserTypeRel createConsumerRel(Long userId) throws UserTypeRelException;

    /**
     * 是否有消费者关联
     */
    boolean hasConsumerRel(Long userId);

    /**
     * 创建区域关联
     */
    List<UserTypeRel> createDivisionRel(Long userId, List<Long> divisionIds) throws UserTypeRelException;

    /**
     * 创建区域关联
     */
    UserTypeRel createCommunityRel(Long userId, Long communityId) throws UserTypeRelException;

    /**
     * 获取区域关联
     *
     * @param userTypeRels
     * @return
     */
    List<UserTypeRel> getDivisionRel(List<UserTypeRel> userTypeRels);

    QResponse<UserTypeRel> findAll(QRequest request, QPage requestPage);

    List<UserTypeRel> findByUserType(UserType userType);

    Long countByUserType(UserType userType);

    Long countUser(UserType userType, LocalDateTime start, LocalDateTime end);

    List<UserTypeRel> findByUserIdAndUserTypeAndObjectType(Long userId, UserType userType, EntityObjectType objectType);

    public void deleteByIdCollection(Collection<Long> idCollection);

    List<UserTypeRel> findUserTypeAndObjectTypeAndObjectId(UserType userType, EntityObjectType objectType, Long objectId);

    List<UserTypeRel> findUserTypeAndObjectTypeAndObjectIdInCollection(UserType userType, EntityObjectType objectType, Collection<Long> objectIdCollection);

}
